package com.atguigu.oss.controller;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OSsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/eduoss/fileoss")
public class OSsController {

    @Autowired
    private OSsService oSsService;

    /**
     * MultipartFile :获取上传文件
     * @param file
     * @return
     */
    //上传头像的方法
    @PostMapping()
    public R uploadOssFile(MultipartFile file) throws IOException {

        String url = oSsService.uploadFileAvatar(file);


        return R.ok().data("url",url);


    }



}
